﻿
@{
    ViewBag.Title = "QC";
    Layout = "~/Views/Shared/_LayoutForEUI.cshtml";
}

<table id="Destroy_QC_grid" class="easyui-datagrid" style="width:100%;" title="销毁清册" data-options="
       rownumbers:true,
       singleSelect:true,
       autoRowHeight:false,
       pagination:true,
       fitColumns:true,
       fit:true,
       striped:true,
       checkOnSelect:false,
       selectOnCheck:false,
       toolbar:'#Destroy_QC_tb',
       collapsible:false,
       pageSize: @SGArchiveSystem7x.Models.CCommonsModels.PageSize,
       pageList:[10,15,20]">
    <thead>
        <tr>
            <th data-options="field:'DES_ID',width:120,align:'center'" formatter="formatShow">查看档案</th>
            <th data-options="field:'DES_V02',width:120,align:'center'" formatter="formatShowPdf">查看附件</th>
            <th data-options="field:'DES_NAME',width:120,align:'center'">清册名</th>
            <th data-options="field:'DES_DATE',width:80,align:'center'" formatter="formatDate">清册建立时间</th>
            <th data-options="field:'DES_CREATEUSERNAME',width:80,align:'center'">清册建立人</th>
            <th data-options="field:'DES_STATUS',width:120,align:'center'" formatter="formatStatus">状态</th>
            <th data-options="field:'DES_ID1',width:80,align:'center'" formatter="formatDestory">确认销毁</th>
        </tr>
    </thead>
</table>
<div id="Destroy_QC_tb" style="padding:5px 10px;">
    <input class="easyui-textbox" label="清册名:" style="width:220px" labelalign="right" labelwidth="70px" id="Destroy_QC_txtName" />
    <select class="easyui-combobox" labelwidth="60px" style="width:220px" id="Destroy_QC_cmStatus" label="状态" labelalign="right" editable="false" panelHeight="auto">
        <option value="-1">全部</option>
        <option value="1">确认销毁中</option>
        <option value="2">已确认销毁</option>
    </select>
    <a href="javascript:void(0);" id="Destroy_Index_btnQuery" class="easyui-linkbutton button-blue" onclick="Search()" style="width:110px;height:30px;">查询</a>
</div>
<div id="Destroy_QC_winDestory" class="easyui-window" title="档案确定销毁" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:370px;height:200px;padding:10px;" maximizable="false" minimizable="false">
    <iframe id="Destroy_QC_frmDestory" src="" frameborder="0" scrolling="no" width="100%" height="150px"></iframe>
</div>
<div id="Destroy_QC_winArchiveInfo" class="easyui-window" title="档案列表" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:800px;height:300px;padding:10px;" maximizable="false" minimizable="false">
    <iframe id="Destroy_QC_frmArchiveInfo" src="" frameborder="0" scrolling="no" width="100%" height="500px"></iframe>
</div>
<script>
    $(document).ready(function () {
        $('#Destroy_QC_grid').datagrid({
            url: '/DestroyArchive/Get_ajaxDestoryArchive?name=&status=-1',
            singleSelect: true,
            method: 'post',
            onLoadSuccess: function (data) {
                $('.pagination-page-list').hide();
            }
        });

        InitPagenation();
    });
    function Search() {
        var name = $('#Destroy_QC_txtName').val();
        var status = $('#Destroy_QC_cmStatus').datebox('getValue');
        $('#Destroy_QC_grid').datagrid('options').url = '/DestroyArchive/Get_ajaxDestoryArchive?name=' + name + "&status=" + status;
        $('#Destroy_QC_grid').datagrid('load');
        $('#Destroy_QC_grid').datagrid('options').pageNumber = 1;
    }
    function formatShowPdf(value, row) {
        if (value == null || value == '')
            return "无"
        return "<a href='javascript:void(0)' onclick='showpdf(\"" + value + "\")'>&nbsp;查看附件</a>";
    }
    function showpdf(value) {
        window.open('../../Content/generic/web/viewer.html?file=/Content/PDF/' + value + "&down=1&print=1");
    }
    function formatShow(value, row) {
        var id = row.DES_ID;
        return "<a href='javascript:void(0)' onclick='show(\"" + id + "\")'>&nbsp;查看档案</a>";
    }
    function show(id)
    {
        document.getElementById('Destroy_QC_frmArchiveInfo').src = '/DestroyArchive/QCArchive?del=' + id;
        $('#Destroy_QC_winArchiveInfo').window('open');
    }
    function formatDestory(value, row) {
        var id = row.DES_ID;
        var qr = row.DES_STATUS;
        return "<a href='javascript:void(0)' onclick='destory(\"" + id + "\",\"" + qr +"\")'><img src='../Content/images/close.png'></img>确认销毁</a>";
    }
    function destory(id, qr) {
        if (qr == "2") {
            $.messager.alert('提示！', '已经销毁过了!', 'info');
        }
        else {
            $.ajax({
                url: "/DestroyArchive/IsKF",
                dataType: "text",
                type: "post",
                data: { 'del': id },
                success: function (data) {
                    if (data == "1") {
                        document.getElementById('Destroy_QC_frmDestory').src = '/DestroyArchive/Destory?id=' + id;
                        $('#Destroy_QC_winDestory').window('open');
                    }
                    else { $.messager.alert('提示！', '存在不在库的档案，请查看档案状态!', 'info'); }
                }
            });           
       }
    }
    function formatStatus(value, row) {
        if (value == 1)
            return "确认销毁中";
        else
            return "已确认销毁";
    }
    function ClosewinUpLoadGrid() {
        $('#Destroy_QC_winDestory').window('close');
        QueryPager($('#Destroy_QC_grid').datagrid('options').pageNumber, $('#Destroy_QC_grid').datagrid('options').pageSize);
    }
    function formatDate(value, row)
    {
        if (value != null) {
            var time = new Date(parseInt(value.substr(6, 19)))//.toLocaleDateString();//13
            return time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate();//+ " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
        }
        else {
            return "";
        }
    }
    ///初始化分页
    function InitPagenation() {
        //设置分页控件
        var p = $('#Destroy_QC_grid').datagrid('getPager');
        $(p).pagination({
            onSelectPage: function (pageNumber, pageSize) {
                QueryPager(pageNumber, pageSize);
            }
        });
    }
    ///分页查询
    function QueryPager(num, size) {
        $('#Destroy_QC_grid').datagrid('options').url = '/DestroyArchive/Get_ajaxDestoryArchivePager?num=' + num + '&size=' + size;
        $('#Destroy_QC_grid').datagrid('reload');
        $('#Destroy_QC_grid').datagrid('options').pageNumber = num;
        $('#Destroy_QC_grid').datagrid('options').pageSize = size;
        return;
    }
</script>

